package com.xtj.workquene;


import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xtj.utils.RabbitMQUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Provider {
    public static void main(String[] args) throws IOException {
        //获取连接对象
        Connection connection = RabbitMQUtils.getConnection();
        //获取通道消息
        Channel channel = connection.createChannel();

        //通过通道声明队列
        channel.queueDeclare("work",true,false,false,null);

        for (int i = 0; i < 10; i++) {
            //生产消息
            channel.basicPublish("","work",null,(i+"hello work quene").getBytes(StandardCharsets.UTF_8));
        }

        //关闭队列
        RabbitMQUtils.closeConnectionAndChanel(channel,connection);
    }

}
